app.controller('ctrl5',['$scope','cart',function($scope,cart){
	$scope.status = cart.status;
	$scope.lists = cart.datas; 
	
	$scope.computes = function(item,num,key){
		item.num += num;
		count();
		if(item.num<=0){
			delete cart.datas[key];
		}
	}
	
	$scope.selectBtn = true;
	$scope.selectAll = function(){
		// $scope.selectBtn
		for(var o in cart.datas){
			cart.datas[o].selec = $scope.selectBtn;
		}
		count();
	}

	$scope.selectFns = function(){
		var status = true;
		for(var o in cart.datas){
			if(!cart.datas[o].selec){
				status = false;
			}
		}
		$scope.selectBtn = status;
		count();
	}
	
	function count(){
		var num=0;
		for(var s in cart.datas){
			if(cart.datas[s].selec){
				num+=cart.datas[s].num*(cart.datas[s].price*100);
			}
		}
		$scope.priceAll=num/100;
	}
	
	count();
	
}])